<template>
    <div class="bottom-nav">
        <div class="nav-item" :class="{ active: currentPath === '/' }" @click="navigateTo('/')">
            <i class="nav-icon"></i>
            <span class="nav-text">首页</span>
        </div>
        <div class="nav-item" :class="{ active: currentPath === '/stockImages' }" @click="navigateTo('/stockImages')">
            <i class="nav-icon"></i>
            <span class="nav-text">持仓数据</span>
        </div>
        <div class="nav-item" :class="{ active: currentPath === '/change/firstCreateWarehouse' }"
             @click="navigateTo('/change/firstCreateWarehouse')">
            <i class="nav-icon"></i>
            <span class="nav-text">涨跌</span>
        </div>
        <div class="nav-item" :class="{ active: currentPath === '/rank/ForecastRanking' }" @click="navigateTo('/rank/ForecastRanking')">
            <i class="nav-icon"></i>
            <span class="nav-text">排名</span>
        </div>
        <div class="nav-item" :class="{ active: currentPath === '/percentile' }" @click="navigateTo('/percentile')">
            <i class="nav-icon"></i>
            <span class="nav-text">百分位</span>
        </div>
        <div class="nav-item" :class="{ active: currentPath === '/filter' }" @click="navigateTo('/filter')">
            <i class="nav-icon"></i>
            <span class="nav-text">筛选</span>
        </div>
    </div>
</template>

<script>
import {computed} from 'vue'
import {useRouter, useRoute} from 'vue-router'

export default {
    name: 'BottomNav',
    setup() {
        const router = useRouter()
        const route = useRoute()

        // 获取当前路径，用于高亮当前导航项
        const currentPath = computed(() => route.path)
        console.log(currentPath.value)
        // 导航到指定路径
        const navigateTo = (path) => {
            router.push(path)
        }

        return {
            currentPath,
            navigateTo
        }
    }
}
</script>

<style scoped>
/* 底部导航 */
.bottom-nav {
    background-color: #fff;
    border-radius: 0;
    padding: 16px 0;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: space-around;
    z-index: 3;
    margin: 0;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.3s;
}

.nav-item.active {
    color: #1890ff;
}

.nav-icon {
    width: 24px;
    height: 24px;
    background-color: #e0e0e0;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-size: 16px;
}

/* 首页图标 */
.nav-item:nth-child(1) .nav-icon::before {
    content: "🏠";
}

/* 涨跌图标 */
.nav-item:nth-child(2) .nav-icon::before {
    content: "📈";
}

/* 涨跌图标 */
.nav-item:nth-child(3) .nav-icon::before {
    content: "📈";
}

/* 排名图标 */
.nav-item:nth-child(4) .nav-icon::before {
    content: "🏆";
}

/* 百分位图标 */
.nav-item:nth-child(5) .nav-icon::before {
    content: "📊";
}

/* 筛选图标 */
.nav-item:nth-child(6) .nav-icon::before {
    content: "🔍";
}

.nav-item.active .nav-icon {
    background-color: #1890ff;
    color: #fff;
}

.nav-text {
    font-size: 12px;
    color: #666;
}

.nav-item.active .nav-text {
    color: #1890ff;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .bottom-nav {
        bottom: 0;
        width: 100%;
        padding: 12px 0;
        border-radius: 0;
    }

    .nav-item {
        gap: 3px;
    }

    .nav-icon {
        width: 22px;
        height: 22px;
        font-size: 14px;
    }

    .nav-text {
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .bottom-nav {
        bottom: 0;
        width: 100%;
        padding: 10px 0;
        border-radius: 0;
    }

    .nav-icon {
        width: 20px;
        height: 20px;
        font-size: 13px;
    }

    .nav-text {
        font-size: 10px;
    }
}

/* 平板设备适配 */
@media (min-width: 769px) and (max-width: 1024px) {
    .bottom-nav {
        max-width: 1024px;
        padding: 14px 0;
    }
}

/* PC端优化 - 保持底部导航栏显示并调整样式 */
@media (min-width: 1200px) {
    .bottom-nav {
        /* 保持显示 */
        display: flex;
        /* PC端样式优化 */
        padding: 18px 0;
        width: 100%;
        max-width: 100%;
        bottom: 0;
        border-radius: 0;
    }

    .nav-item {
        gap: 6px;
    }

    .nav-icon {
        width: 26px;
        height: 26px;
        font-size: 18px;
    }

    .nav-text {
        font-size: 13px;
        font-weight: 500;
    }
}
</style>
